#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QPixmap pixmap = QPixmap(":/picture/backgrond.bmp").scaled(this->size());
    QPalette palette(this->palette());
    palette.setBrush(QPalette::Background, QBrush(pixmap));
    this->setPalette(palette);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{

    hid_init();
    hid_device_info *hid_info;
    hid_info = hid_enumerate(0, 0);
    while(hid_info != NULL)
    {
        if(hid_info->vendor_id == MULT_PUSHROD_VID
        && hid_info->product_id == MULT_PUSHROD_PID
        && hid_info->interface_number == MULT_PUSHROD_INTERFACE)
        {
            qDebug("%s",hid_info->path);
//            qDebug("%s",hid_info->serial_number);
//            qDebug("%s",hid_info->manufacturer_string);
//            qDebug("%s",hid_info->product_string);
//            qDebug("%x",hid_info->usage_page);
//            qDebug("%x",hid_info->usage);
            mult_pr_handle = hid_open_path(hid_info->path);
            if(mult_pr_handle != NULL)
            {
                qDebug() << "open success." << endl;
            }
        }
        hid_info = hid_info->next;
    }
    hid_free_enumeration(hid_info);
}
